
package com.probiz.estore.exception;

import com.probiz.estore.common.model.sales.GiftCertificate;
import com.probiz.estore.core.util.I18nUtil;

public class GiftCertificateStateException extends Exception {

	private static final long	serialVersionUID	= 1L;
	private String				giftCertificateNo;
	private short				state				= GiftCertificate.STATE_INVALID;

	public GiftCertificateStateException() {
		super();
	}

	public GiftCertificateStateException(String giftCertificateNo, short state) {
		super();
		this.setGiftCertificateNo(giftCertificateNo);
		this.setState(state);
	}

	public short getState() {
		return state;
	}

	public void setState(short state) {
		this.state = state;
	}

	public String getGiftCertificateNo() {
		return giftCertificateNo;
	}

	public void setGiftCertificateNo(String giftCertificateNo) {
		this.giftCertificateNo = giftCertificateNo;
	}

	@Override
	public String getMessage() {
		if (state == GiftCertificate.STATE_EXPIRE.shortValue()) {
			return I18nUtil.getInstance().getMessage("giftCertificate.error.expire");
		} else 
		if (state == GiftCertificate.STATE_INVALID.shortValue()) {
			return I18nUtil.getInstance().getMessage("giftCertificate.error.notAgiftCertificate");
		} else 
		if (state == GiftCertificate.STATE_NOT_ENOUGH_REMAINEDAMT.shortValue()) {
			return I18nUtil.getInstance().getMessage("giftCertificate.error.noMoney");
		} else 
		if (state == GiftCertificate.STATE_REMAINEDAMT_IS_ZERO.shortValue()) {
			return I18nUtil.getInstance().getMessage("giftCertificate.error.moneyNull");
		} else 			
		if (state == GiftCertificate.STATE_UNACTIVE.shortValue()) {
			return I18nUtil.getInstance().getMessage("giftCertificate.error.inactive");
		} else {
			return I18nUtil.getInstance().getMessage("giftCertificate.error.onUsing");
		}
	}
}
